package com.lab.idea.bl.listen;

import com.lab.idea.bl.util.TipWindow;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.context.event.ApplicationFailedEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;
import org.springframework.web.context.WebApplicationContext;

import javax.annotation.Resource;

/**
 * 项目启动失败
 * @author mao
 */
@Component
public class StartFailedEventListener implements ApplicationListener<ApplicationFailedEvent> {

    @Resource
    private WebApplicationContext applicationContext;


    @Override
    public void onApplicationEvent(ApplicationFailedEvent event) {
        TipWindow.show("启动失败!!!",5000);
        System.exit(SpringApplication.exit(applicationContext));
    }
}
